CUBE CONNECT Edition Help

Delete links or nodes based on attribute value with the CubeDatabase class

A LinkEntry vector needs to be defined to use the removeLinks() method, this is a list of LinkEntries. For example, assuming that we would like to delete links from the network based on an attribute value (e.g., func_class) we can define a LinkEntry vector as below (LinkEntry(int a, int b)):
net_links_list = []
while net_links.next():  # looping through the links
    if net_links.real("func_class") == 6:  # functional class = 6 (local)
        link_entry = cp.LinkEntry(net_links.a(), net_links.b())          
	net_links_list.append(link_entry)  # appending to the list   

The removeLinks(network name, link entries vector) method can then be used as below:

db.removeLinks(network_name, net_links_list)

Similarly, the removeNodes() method takes as arguments the network name and a list of node numbers. When deleting nodes, the user should notice that also connected links are automatically removed from the network.

To remove disconnected nodes and links, two additional methods can be used to define the list of disconnected nodes and the LinkEntry object respectively:

disc_nodes = db.disconnectedNodes(network_name)  # return a list object with the disconnected nodes
disc_links = db.disconnectedLinks(network_name)  # return a LinkEntry object with the disconnected links

These objects can then be passed to the removeNodes and removeLinks method respectively.

In addition to deleting user defined links or nodes, two “special” methods are provided to delete specifically centroid connectors (links), centroids (nodes) and dangling links (links with at least one node not connected to other links, excluding centroid connectors) these are:

  • removeCentroidConnectors(), with the network name as attribute
  • removeCentroids(), taking the network name as only attribute
  • removeDanglingLinks(), again with the network name as only attribute